//
//  TopListTableViewCell.m
//  WXMusic
//
//  Created by 漫步人生路 on 15/9/2.
//  Copyright (c) 2015年 漫步人生路. All rights reserved.
//

#import "TopListTableViewCell.h"

@implementation TopListTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        //初始化专辑图
        self.topListPic = [[UIImageView alloc]initWithFrame:CGRectMake(10, 15, kWidth / (375.0 / 150.0), kWidth / (375.0 / 150.0))];
        [self.contentView addSubview:self.topListPic];
        
        //初始化榜单名
        self.topListName = [[UILabel alloc]initWithFrame:CGRectMake(30+self.topListPic.bounds.size.width, 15, 100, 30)];
        [self setUpLabel:self.topListName font:[UIFont boldSystemFontOfSize:17.0]];
        [self.contentView addSubview:self.topListName];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(30 + self.topListPic.bounds.size.width, 45, kWidth - 30 - self.topListPic.bounds.size.width - 30, 1)];
        lineView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:lineView];
        
        for (int i = 0; i < 4; i++) {
            UILabel *numLabel = [[UILabel alloc]initWithFrame:CGRectMake(30 + self.topListPic.bounds.size.width, 60 + i * 25, 15, 15)];
            numLabel.text = [NSString stringWithFormat:@"%d",i + 1];
            numLabel.textColor = [UIColor orangeColor];
            numLabel.font = [UIFont fontWithName:nil size:13.0];
            [self.contentView addSubview:numLabel];
            
            UILabel *songsName = [[UILabel alloc]initWithFrame:CGRectMake(45 + self.topListPic.bounds.size.width, 60 + i * 25, kWidth - 30 - self.topListPic.bounds.size.width - 30, 15)];
            songsName.tag = i + 1000;
            [self setUpLabel:songsName font:[UIFont boldSystemFontOfSize:15.0]];
            [self.contentView addSubview:songsName];
        }
    }
    return self;
}
//根据model赋值
- (void)setValueWithModel:(TopListModel *)model songsInfoArray:(NSMutableArray *)songsInfoArray songsInfoModel:(TopListModel *)songsInfoModel
{
    [self.topListPic sd_setImageWithURL:[NSURL URLWithString:model.pic_s192]];
    self.topListName.text = model.name;
    for (int i = 0; i < model.content.count; i++) {
        UILabel *songsLabel = (UILabel *)[self viewWithTag:i + 1000];
        songsInfoModel = [TopListModel shareJsonWithDictionary:[model.content objectAtIndex:i]];
//        songsInfoModel = [model.content objectAtIndex:i];
        songsLabel.text = [[songsInfoModel.title stringByAppendingString:@"-"] stringByAppendingString:songsInfoModel.author];

    }
}
- (void)setUpLabel:(UILabel *)label font:(UIFont *)font
{
    label.textColor = [UIColor whiteColor];
    label.font = font;
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
